<%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2022-03-26
  Time: 16:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h2>注册新生</h2>
<form method="post" action="uploadServlet" enctype="multipart/form-data">
    <p>
        <label>姓名</label><input type="text" required name="sname"/>
    </p>
    <p>
        <label>QQ</label><input type="text" required name="qq"/>
    </p>

    <p>
        <label>微信号</label><input type="text" required name="wechat"/>
    </p>
    <p>
        <label>年级</label>
        <select name="gradeid" id="gradeid">

        </select>
    </p>
    <p>
        <label>身份证照片正面</label><input type="file" required name="idcard" accept="image/png|jpg|gif" onchange="showPreview(this, 'preview')"/>
        <img src="#" id="preview" height="200px" width="200px">
    </p>
    <p>
        <input type="submit" value="注册"/>
    </p>
</form>
<script>
    function showPreview(source, imgId) {
        var file = source.files[0];
        if(window.FileReader) {
            var fr = new FileReader();
            fr.onloadend = function(e) {
                document.getElementById(imgId).src = e.target.result;
            }
            fr.readAsDataURL(file);
        }
    }
</script>
</body>
</html>
